/********************************************************************
	TABAL ENGINE - 2012/10/31
	author:		Marc Cuscullola
	
	purpose:	Defines the manager to render the game
*********************************************************************/
#pragma once

#ifndef __RENDER_MANAGER__INLUDED_H__
#define __RENDER_MANAGER__INLUDED_H__

#pragma warning (disable:4005)

#include "Singleton/Singleton.h"
#include <Windows.h>
#include <windowsx.h>
#include <d3d11.h>
#include <d3dx11.h>
#include <string>
#include <xnamath.h>
#include "Vector\Vector2.h"
#include "Matrix\Matrix44.h"

class CCamera;
class CEffectManager;

#define RENDER_MANAGER CRenderManager::GetSingletonPtr()

class CRenderManager : public CSingleton<CRenderManager>
{
public:
	CRenderManager();
	virtual ~CRenderManager();

	// Init graphic engine (DirectX 11)
	bool		Initialize		(HWND _hWnd);
	void		Uninitialize	();

	// Render process methods
	void		BeginRendering	();
	void		EndRendering	();
	void		SetupMatrices	(CCamera* _pCamera = NULL);
	void		ClearTarget		();

	// Aply a transform to the objects rendered after that
	void		SetTransform	(const Mat44f& _mat);

	// Flags to modify the render
	inline void EnableZBuffer			();
	inline void	DisableZBuffer			();
	inline void EnableAlphaBlending		();
	inline void DisableAlphaBlending	();

	// Get Methods
	inline const Vect2u&			GetScreenSize		() const;
	inline ID3D11Device*			GetDevice			() const;
	inline ID3D11DeviceContext*		GetDeviceContext	() const;
	inline CEffectManager*			GetEffectManager	() const;

private:
	Vect2u						m_ScreenSize;	
	CEffectManager*				m_pEffectManager;

	// D3DX11 Pointers
	IDXGISwapChain*				m_pSwapChain;
	ID3D11Device*				m_pDevice;
	ID3D11DeviceContext*		m_pDeviceContext;
	ID3D11RenderTargetView*		m_pRenderTargetView;
	ID3D11Texture2D*			m_pDepthStencil;
	ID3D11DepthStencilView*		m_pDepthStencilView;
	ID3D11RasterizerState*		m_pRasterizerState;

	ID3D11DepthStencilState*	m_pDepthEnableState;
	ID3D11DepthStencilState*	m_pDepthDisbaleState;
	ID3D11BlendState*			m_pAlphaBlendingEnableState;
	ID3D11BlendState*			m_pAlphaBlendingDisableState;
};

#include "RenderManager.inl"

#endif